package com.game.league.mine.detail;

import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.game.base.app.base.BaseActivity;
import com.game.league.R;
import com.game.league.databinding.ActivityCoinDetailBinding;
import com.game.league.mine.detail.adapter.FlowBillAdapter;
import com.game.league.mine.table.FlowBill;
import com.game.league.service.InterfaceMgr;

import java.util.ArrayList;
import java.util.List;

import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.FindListener;

/**
 * 收支明细记录
 * Created by Su on 2019/6/11.
 */
public class FlowBillActivity extends BaseActivity<ActivityCoinDetailBinding> implements View.OnClickListener {
    private FlowBillAdapter adapter;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_coin_detail;
    }

    @Override
    protected void initView() {
        binding.setTitle("收支明细");
        binding.setClick(this);

        binding.customFrameLayout.show(com.game.base.R.id.emptyView);
        binding.emptyView.show(true);
        binding.recyclerList.setLayoutManager(new LinearLayoutManager(this));
        adapter = new FlowBillAdapter();
        binding.recyclerList.setAdapter(adapter);
    }

    @Override
    protected void initData() {
        InterfaceMgr.getInstance().getFlowBillList(new FindListener<FlowBill>() {
            @Override
            public void done(List<FlowBill> list, BmobException e) {
                if (list == null || list.isEmpty()) {
                    binding.emptyView.show("暂无数据", null);
                    return;
                }
                adapter.setItems((ArrayList<FlowBill>) list);
                binding.customFrameLayout.show(R.id.recycler_list);
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.title_left_iv:
                finish();
                break;
        }
    }
}
